//
//  CPDStockPriceStore.m
//  CorePlotDemo
//
//  NB: Price data obtained from Yahoo! Finance:
//  http://finance.yahoo.com/q/hp?s=AAPL
//  http://finance.yahoo.com/q/hp?s=GOOG
//  http://finance.yahoo.com/q/hp?s=MSFT
//
//  Created by Steve Baranski on 5/4/12.
//  Copyright (c) 2012 komorka technology, llc. All rights reserved.
//

#import "CPDStockPriceStore.h"
#import "CPDConstants.h"
#import "ParserClass.h"
#import "Devices.h"
#import "DevicesCurrentTemperature-PGS.h"
#import "DevicesCurrentTemperature-Platinum.h"
#import "DevicesCurrentTemperature-CO2Incubator.h"
#import "DevicesCurrentTemperature-EGS-G2.h"
#import "DevicesCurrentTemperature-OFA_IFA_IFC_INA.h"


@interface CPDStockPriceStore ()
{
    NSMutableArray *arrDevice;
    NSMutableArray *arrTimeDates;
}

@end

@implementation CPDStockPriceStore

#pragma mark - Class methods

+ (CPDStockPriceStore *)sharedInstance
{
    static CPDStockPriceStore *sharedInstance;
    
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        sharedInstance = [[self alloc] init];      
    });
    
    return sharedInstance;
}

#pragma mark - API methods

- (NSArray *)tickerSymbols
{
    static NSArray *symbols = nil;
    if (!symbols)
    {
        symbols = [NSArray arrayWithObjects:
                   @"AAPL", 
                   @"GOOG", 
                   @"MSFT", 
                   nil];
    }
    return symbols;
}

- (NSArray *)dailyPortfolioPrices
{
    static NSArray *prices = nil;
    if (!prices)
    {
        prices = [NSArray arrayWithObjects:
                  [NSDecimalNumber numberWithFloat:582.13], 
                  [NSDecimalNumber numberWithFloat:604.43], 
                  [NSDecimalNumber numberWithFloat:32.01], 
                  nil];
    }
    return prices;
}

- (NSArray *)datesInWeek
{
    static NSArray *dates = nil;
    if (!dates)
    {
        dates = [NSArray arrayWithObjects:
                 @"4/23", 
                 @"4/24", 
                 @"4/25",
                 @"4/26", 
                 @"4/27",                   
                 nil];
    }
    return dates;
}

- (NSArray *)weeklyPrices:(NSString *)tickerSymbol
{
    if ([CPDTickerSymbolAAPL isEqualToString:[tickerSymbol uppercaseString]] == YES)
    {
        return [self weeklyAaplPrices];
    }
    else if ([CPDTickerSymbolGOOG isEqualToString:[tickerSymbol uppercaseString]] == YES)
    {
        return [self weeklyGoogPrices];
    }
    else if ([CPDTickerSymbolMSFT isEqualToString:[tickerSymbol uppercaseString]] == YES)
    {
        return [self weeklyMsftPrices];
    }
    return [NSArray array];
}

- (NSArray *)datesInMonth
{
//    static NSArray *dates = nil;
//    if (!dates)
//    {
//
//       // dates = [NSArray arrayWithObjects:[self devicesArrTime], nil];
//        dates = [self devicesArrTime];
////        dates = [NSArray arrayWithObjects:
////                 @"2", 
////                 @"3", 
////                 @"4",
////                 @"5",
////                 @"9", 
////                 @"10", 
////                 @"11",
////                 @"12", 
////                 @"13",
////                 @"16", 
////                 @"17", 
////                 @"18",
////                 @"19", 
////                 @"20", 
////                 @"23", 
////                 @"24", 
////                 @"25",
////                 @"26", 
////                 @"27",
////                 @"30",                   
////                 nil];
//
//    }
    return arrTimeDates;
    
    //[self devicesArrTimeData];
}

- (NSMutableArray*)devicesArrTimeData{
    
    NSMutableArray *arrTimeDate = [NSMutableArray array];
    
    for (int i = 0; i < [[[ParserClass sharedItems] sensorLogs] count] ; i++) {
        
        //            Devices *devices = [[ParserClass sharedItems] sensorLogs][i];
        //            DevicesCurrentTemperature_PGS *devicesGoldSilver = [[ParserClass sharedItems] sensorLogs][i];
        //
        //            DevicesCurrentTemperature_CO2Incubator *devicesIncubator = [[ParserClass sharedItems] sensorLogs][i];
        //            DevicesCurrentTemperature_EGS_G2 *devicesEGSG2 = [[ParserClass sharedItems] sensorLogs][i];
        //            DevicesCurrentTemperature_OFA_IFA_IFC_INA *devicesOFAIFAIFCINA ;
        
        DevicesCurrentTemperature_Platinum *devicesPlatinum = [[ParserClass sharedItems] sensorLogs][i];
        
        //  dates = [NSArray arrayWithObjects:[devicesPlatinum occuranceTime], nil];
        
//        dates = [NSArray arrayWithObject:[devicesPlatinum occuranceTime]];
        
        [arrTimeDate addObject:[devicesPlatinum occuranceTime]];
        
    }
    
    NSLog(@"arrTime = %i", [arrTimeDate count]);
    
    return arrTimeDate;


    
}

- (NSArray *)monthlyPrices:(NSString *)tickerSymbol
{
    if ([CPDTickerSymbolAAPL isEqualToString:[tickerSymbol uppercaseString]] == YES)
    {
        return [self monthlyAaplPrices];
    }
    else if ([CPDTickerSymbolGOOG isEqualToString:[tickerSymbol uppercaseString]] == YES)
    {
        return [self monthlyGoogPrices];
    }
    else if ([CPDTickerSymbolMSFT isEqualToString:[tickerSymbol uppercaseString]] == YES)
    {
        return [self monthlyMsftPrices];
    }
    return [NSArray array];
}

#pragma mark - Private behavior

- (NSArray *)weeklyAaplPrices
{
    static NSArray *prices = nil;
    if (!prices)
    {
        prices = [NSArray arrayWithObjects:
                  [NSDecimalNumber numberWithFloat:571.70], 
                  [NSDecimalNumber numberWithFloat:560.28], 
                  [NSDecimalNumber numberWithFloat:610.00], 
                  [NSDecimalNumber numberWithFloat:607.70], 
                  [NSDecimalNumber numberWithFloat:603.00],                   
                  nil];
    }
    return prices;
}

- (NSArray *)weeklyGoogPrices
{
    static NSArray *prices = nil;
    if (!prices)
    {
        prices = [NSArray arrayWithObjects:
                  [NSDecimalNumber numberWithFloat:597.60], 
                  [NSDecimalNumber numberWithFloat:601.27], 
                  [NSDecimalNumber numberWithFloat:609.72], 
                  [NSDecimalNumber numberWithFloat:615.47], 
                  [NSDecimalNumber numberWithFloat:614.98],                   
                  nil];
    }
    return prices;
}

- (NSArray *)weeklyMsftPrices
{
    static NSArray *prices = nil;
    if (!prices)
    {
        prices = [NSArray arrayWithObjects:
                  [NSDecimalNumber numberWithFloat:32.12], 
                  [NSDecimalNumber numberWithFloat:31.92], 
                  [NSDecimalNumber numberWithFloat:32.20], 
                  [NSDecimalNumber numberWithFloat:32.11], 
                  [NSDecimalNumber numberWithFloat:31.98],                   
                  nil];
    }
    return prices;
}

- (NSArray *)monthlyAaplPrices
{
//    static NSArray *prices = nil;
//    if (!prices)
//    {
//        
//
////        prices = [NSArray arrayWithObjects:
////                  [NSDecimalNumber numberWithFloat:90.92],
////                  [NSDecimalNumber numberWithFloat:42.62],
////                  [NSDecimalNumber numberWithFloat:35.15],
////                  [NSDecimalNumber numberWithFloat:32.32],
////                  [NSDecimalNumber numberWithFloat:30.84],
////                  [NSDecimalNumber numberWithFloat:26.86],
////                  [NSDecimalNumber numberWithFloat:35.96],
////                  [NSDecimalNumber numberWithFloat:51.01],
////                  [NSDecimalNumber numberWithFloat:24.60],
////                  [NSDecimalNumber numberWithFloat:6.07],
////                  [NSDecimalNumber numberWithFloat:9.57],
////                  [NSDecimalNumber numberWithFloat:7.45],
////                  [NSDecimalNumber numberWithFloat:99.30],
////                  [NSDecimalNumber numberWithFloat:96.06],
////                  [NSDecimalNumber numberWithFloat:97.60],
////                  [NSDecimalNumber numberWithFloat:1.27],
////                  [NSDecimalNumber numberWithFloat:9.72],
////                  [NSDecimalNumber numberWithFloat:15.47],
////                  [NSDecimalNumber numberWithFloat:14.98],
////                  [NSDecimalNumber numberWithFloat:4.85],
////                  nil];
//        
//       // prices = [NSArray arrayWithObjects:[self devicesArr], nil];
//    
//        
//        prices = [self devicesArr];
//    }
    return arrDevice;
}


- (NSArray *)monthlyGoogPrices
{
//    static NSArray *prices = nil;
//    if (!prices)
//    {
//        prices = [NSArray arrayWithObjects:
//                  [NSDecimalNumber numberWithFloat:146.92],
//                  [NSDecimalNumber numberWithFloat:142.62],
//                  [NSDecimalNumber numberWithFloat:135.15],
//                  [NSDecimalNumber numberWithFloat:132.32],
//                  [NSDecimalNumber numberWithFloat:130.84],
//                  [NSDecimalNumber numberWithFloat:126.86],
//                  [NSDecimalNumber numberWithFloat:135.96],
//                  [NSDecimalNumber numberWithFloat:151.01],
//                  [NSDecimalNumber numberWithFloat:124.60],
//                  [NSDecimalNumber numberWithFloat:106.07],
//                  [NSDecimalNumber numberWithFloat:109.57],
//                  [NSDecimalNumber numberWithFloat:107.45],
//                  [NSDecimalNumber numberWithFloat:199.30],
//                  [NSDecimalNumber numberWithFloat:196.06],
//                  [NSDecimalNumber numberWithFloat:197.60],
//                  [NSDecimalNumber numberWithFloat:101.27],
//                  [NSDecimalNumber numberWithFloat:609.72], 
//                  [NSDecimalNumber numberWithFloat:615.47], 
//                  [NSDecimalNumber numberWithFloat:614.98], 
//                  [NSDecimalNumber numberWithFloat:604.85],                  
//                  nil];
//    }
    return arrDevice;
}

- (NSArray *)monthlyMsftPrices
{
//    static NSArray *prices = nil;
//    if (!prices)
//    {
//        prices = [NSArray arrayWithObjects:
//                  [NSDecimalNumber numberWithFloat:0.29],
//                  [NSDecimalNumber numberWithFloat:0.94],
//                  [NSDecimalNumber numberWithFloat:0.21],
//                  [NSDecimalNumber numberWithFloat:0.52],
//                  [NSDecimalNumber numberWithFloat:0.10],
//                  [NSDecimalNumber numberWithFloat:0.47],
//                  [NSDecimalNumber numberWithFloat:0.35],
//                  [NSDecimalNumber numberWithFloat:0.98],
//                  [NSDecimalNumber numberWithFloat:0.81],
//                  [NSDecimalNumber numberWithFloat:0.08],
//                  [NSDecimalNumber numberWithFloat:0.44],
//                  [NSDecimalNumber numberWithFloat:0.14],
//                  [NSDecimalNumber numberWithFloat:0.01],
//                  [NSDecimalNumber numberWithFloat:0.42],
//                  [NSDecimalNumber numberWithFloat:0.12],
//                  [NSDecimalNumber numberWithFloat:0.92],
//                  [NSDecimalNumber numberWithFloat:0.20],
//                  [NSDecimalNumber numberWithFloat:0.11],
//                  [NSDecimalNumber numberWithFloat:0.98],
//                  [NSDecimalNumber numberWithFloat:0.02],
//                  nil];
//    }
    return arrDevice;
}

- (NSMutableArray*)devicesArr{
    
    
    NSMutableArray *arrDevices = [NSMutableArray array];
    
    for (int i = 0; i < [[[ParserClass sharedItems] sensorLogs] count] ; i++) {
        
        //            Devices *devices = [[ParserClass sharedItems] sensorLogs][i];
        //            DevicesCurrentTemperature_PGS *devicesGoldSilver = [[ParserClass sharedItems] sensorLogs][i];
        //
        //            DevicesCurrentTemperature_CO2Incubator *devicesIncubator = [[ParserClass sharedItems] sensorLogs][i];
        //            DevicesCurrentTemperature_EGS_G2 *devicesEGSG2 = [[ParserClass sharedItems] sensorLogs][i];
        //            DevicesCurrentTemperature_OFA_IFA_IFC_INA *devicesOFAIFAIFCINA ;
        
        DevicesCurrentTemperature_Platinum *devicesPlatinum = [[ParserClass sharedItems] sensorLogs][i];
        
        // prices = [NSArray arrayWithObjects:[devicesPlatinum condenserOutletSensor], nil];
        
        [arrDevices addObject:[devicesPlatinum condenserOutletSensor]];
    }
    
    NSLog(@"arrDevices = %i", [arrDevices count]);
    return arrDevices;
    
    
    
}



/////

- (void)devicesArrTimeFromDate:(NSString*)fromDate andToDate:(NSString*)toDate{
    
    NSLog(@"From = %@ and To = %@ ", fromDate, toDate);
    
    int j = [toDate intValue];
    
   arrTimeDates = [NSMutableArray array];
    
    for (int i = [fromDate intValue]; i < j ; i++) {
        
//        //            Devices *devices = [[ParserClass sharedItems] sensorLogs][i];
//        //            DevicesCurrentTemperature_PGS *devicesGoldSilver = [[ParserClass sharedItems] sensorLogs][i];
//        //
//        //            DevicesCurrentTemperature_CO2Incubator *devicesIncubator = [[ParserClass sharedItems] sensorLogs][i];
//        //            DevicesCurrentTemperature_EGS_G2 *devicesEGSG2 = [[ParserClass sharedItems] sensorLogs][i];
//        //            DevicesCurrentTemperature_OFA_IFA_IFC_INA *devicesOFAIFAIFCINA ;
//        
//        DevicesCurrentTemperature_Platinum *devicesPlatinum = [[ParserClass sharedItems] sensorLogs][i];
//        
//        //  dates = [NSArray arrayWithObjects:[devicesPlatinum occuranceTime], nil];
//        
//        //        dates = [NSArray arrayWithObject:[devicesPlatinum occuranceTime]];
//        
//        [arrTimeDate addObject:[devicesPlatinum occuranceTime]];
        
        Devices *devices = [[ParserClass sharedItems] sensorLogs][i];
        
        if ([[devices deviceType] isEqualToString:@"ultf_silver"] || [[devices deviceType] isEqualToString:@"ultf_gold"]) {
            
            NSLog(@"gold silver");
            
            DevicesCurrentTemperature_PGS *devicesGoldSilver = [[ParserClass sharedItems] sensorLogs][i];
            
            
            
            [arrTimeDates addObject:[devicesGoldSilver occuranceTime]];
            
            
        }else if ([[devices deviceType] isEqualToString:@"ultf_platinum"]){
            
            NSLog(@"platinum");
            
            DevicesCurrentTemperature_Platinum *devicesPlatinum = [[ParserClass sharedItems] sensorLogs][i];
            
           [arrTimeDates addObject:[devicesPlatinum occuranceTime]];
            
    
            
        }else if ([[devices deviceType] isEqualToString:@"co2_incubator"]){
            
            NSLog(@"incubator");
            
            DevicesCurrentTemperature_CO2Incubator *devicesIncubator = [[ParserClass sharedItems] sensorLogs][i];
            
            [arrTimeDates addObject:[devicesIncubator occuranceTime]];
            
        }else if ([[devices deviceType] isEqualToString:@"ecs-g2"]){
            
            NSLog(@"Ecs g2");
            
            DevicesCurrentTemperature_EGS_G2 *devicesEGSG2 = [[ParserClass sharedItems] sensorLogs][i];
            
            [arrTimeDates addObject:[devicesEGSG2 occuranceTime]];
            
        }else if ([[devices deviceType] isEqualToString:@"ofa"] || [[devices deviceType] isEqualToString:@"ifa"] || [[devices deviceType] isEqualToString:@"ifc"] || [[devices deviceType] isEqualToString:@"ina"]){
            
            NSLog(@"ofa ifa ifc ina");
            
            DevicesCurrentTemperature_OFA_IFA_IFC_INA *devicesOFAIFAIFCINA = [[ParserClass sharedItems] sensorLogs][i];
            
            [arrTimeDates addObject:[devicesOFAIFAIFCINA occuranceTime]];
        }
    }
    
    NSLog(@"arrTime = %i", [arrTimeDates count]);
    
    //return arrTimeDate;
    
    
    
    
    
}
- (void)devicesArr:(NSString*)deviceType{
    
    
    arrDevice = [NSMutableArray array];
    
    for (int i = 0; i < [[[ParserClass sharedItems] sensorLogs] count] ; i++) {
        
        Devices *devices = [[ParserClass sharedItems] sensorLogs][i];
        
        if ([[devices deviceType] isEqualToString:@"ultf_silver"] || [[devices deviceType] isEqualToString:@"ultf_gold"]) {
            
            NSLog(@"gold silver");
            
            DevicesCurrentTemperature_PGS *devicesGoldSilver = [[ParserClass sharedItems] sensorLogs][i];
            
            //  cell.lblDate.text = [devicesGoldSilver occuranceTime];
            
            
            if ([deviceType isEqualToString:@"Chamber Set Point"]) {
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesGoldSilver chamberSetPoint]];
                
                [arrDevice addObject:[devicesGoldSilver chamberSetPoint]];
                
            }else if ([deviceType isEqualToString:@"High Temperature Limit"]){
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesGoldSilver highTemperatureLimit]];
                
                [arrDevice addObject:[devicesGoldSilver highTemperatureLimit]];
                
            }else if ([deviceType isEqualToString:@"Low Temperature Limit"]){
                
                //   cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesGoldSilver lowTemperatureLimit]];
                
                [arrDevice addObject:[devicesGoldSilver lowTemperatureLimit]];
                
            }else if ([deviceType isEqualToString:@"Chamber Temperature Sensor"]){
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesGoldSilver chamberTemperatureSensor]];
                
                [arrDevice addObject:[devicesGoldSilver chamberTemperatureSensor]];
                
            }else if ([deviceType isEqualToString:@"NTC Ambient Sensor"]){
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesGoldSilver ntcAmbientSensor]];
                
                [arrDevice addObject:[devicesGoldSilver ntcAmbientSensor]];
                
            }else if ([deviceType isEqualToString:@"NTC Condenser Sensor"]){
                
                //  cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesGoldSilver ntcCondenserSensor]];
                
                [arrDevice addObject:[devicesGoldSilver ntcCondenserSensor]];
                
            }else if ([deviceType isEqualToString:@"NTC Heat Exchanger 1"]){
                
                //   cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesGoldSilver ntcHeatExchanger1]];
                
                [arrDevice addObject:[devicesGoldSilver ntcHeatExchanger1]];
                
            }else if ([deviceType isEqualToString:@"NTC Heat Exchanger 2"]){
                
                //  cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesGoldSilver ntcHeatExchanger2]];
                
                [arrDevice addObject:[devicesGoldSilver ntcHeatExchanger2]];
                
            }else if ([deviceType isEqualToString:@"AC Voltage"]){
                
                //  cell.lblTemp.text = [NSString stringWithFormat:@"%@",[devicesGoldSilver acVoltage]];
                
                [arrDevice addObject:[devicesGoldSilver acVoltage]];
            }
            
        }else if ([[devices deviceType] isEqualToString:@"ultf_platinum"]){
            
            NSLog(@"platinum");
            
            DevicesCurrentTemperature_Platinum *devicesPlatinum = [[ParserClass sharedItems] sensorLogs][i];
            
            //       cell.lblDate.text = [devicesPlatinum occuranceTime];
            
            
            if ([deviceType isEqualToString:@"Chamber Set Point"]) {
                //  cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesPlatinum chamberSetPoint]];
                
//                NSMutableArray *arr = [NSMutableArray array];
//                [arr addObject:[devicesPlatinum chamberSetPoint]];
//                
//                
//                arrDevice = [[arr reverseObjectEnumerator] allObjects];
             //   arrDevice = [[[arrDevice reverseObjectEnumerator] allObjects] mutableCopy];
                
                [arrDevice addObject:[devicesPlatinum chamberSetPoint]];
                
                
                
            }else if ([deviceType isEqualToString:@"High Temperature Limit"]){
                
                //   cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesPlatinum highTemperatureLimit]];
                
                [arrDevice addObject:[devicesPlatinum highTemperatureLimit]];
                
            }else if ([deviceType isEqualToString:@"Low Temperature Limit"]){
                
                //    cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesPlatinum lowTemperatureLimit]];
                
                [arrDevice addObject:[devicesPlatinum lowTemperatureLimit]];
                
            }else if ([deviceType isEqualToString:@"Chamber Temperature Sensor"]){
                
                //   cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesPlatinum chamberTemperatureSensor]];
                
                [arrDevice addObject:[devicesPlatinum chamberTemperatureSensor]];
                
            }else if ([deviceType isEqualToString:@"Ambient Sensor"]){
                
                //  cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesPlatinum ambientSensor]];
                
                [arrDevice addObject:[devicesPlatinum ambientSensor]];
                
            }else if ([deviceType isEqualToString:@"Condenser Outlet Sensor"]){
                
                //  cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesPlatinum condenserOutletSensor]];
                
                [arrDevice addObject:[devicesPlatinum condenserOutletSensor]];
                
            }else if ([deviceType isEqualToString:@"Heat Exchanger Temperature Sensor"]){
                
                //   cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesPlatinum heatExchangerTempSensor]];
                
                [arrDevice addObject:[devicesPlatinum heatExchangerTempSensor]];
                
            }else if ([deviceType isEqualToString:@"Evap In Sensor"]){
                
                //   cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesPlatinum evapInSensor]];
                [arrDevice addObject:[devicesPlatinum evapInSensor]];
                
            }else if ([deviceType isEqualToString:@"Evap Out Sensor"]){
                
                //   cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesPlatinum evapOutSensor]];
                
                [arrDevice addObject:[devicesPlatinum evapInSensor]];
                
            }else if ([deviceType isEqualToString:@"Battery Voltage"]){
                
                //    cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesPlatinum batteryVoltage]];
                
                [arrDevice addObject:[devicesPlatinum batteryVoltage]];
                
            }else if ([deviceType isEqualToString:@"AC Voltage"]){
                
                //  cell.lblTemp.text = [NSString stringWithFormat:@"%@",[devicesPlatinum acVoltage]];
                
                [arrDevice addObject:[devicesPlatinum acVoltage]];
                
            }else if ([deviceType isEqualToString:@"High Stage"]){
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@",[devicesPlatinum highStage]];
                
                [arrDevice addObject:[devicesPlatinum highStage]];
                
            }
            //cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesPlatinum chamberTemperatureSensor]];
            
        }else if ([[devices deviceType] isEqualToString:@"co2_incubator"]){
            
            NSLog(@"incubator");
            
            DevicesCurrentTemperature_CO2Incubator *devicesIncubator = [[ParserClass sharedItems] sensorLogs][i];
            
            //    cell.lblDate.text = [devicesIncubator occuranceTime];
            
            //        occuranceTime,!temperatureSetPoint,!co2SetPoint,!o2SetPoint,!highTemperatureLimit,! lowTemperatureLimit,!highCo2Limit,!lowCo2Limit,!highO2Limit,!lowO2Limit,!lowRhLimit,! temperatureSensor,!co2Sensor,!o2Sensor,!rhSensor!
            
            if ([deviceType isEqualToString:@"Temperature Set Point"]) {
                
                //cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator temperatureSetPoint]];
                
                [arrDevice addObject:[devicesIncubator temperatureSetPoint]];
                
            } else if ([deviceType isEqualToString:@"Co2 Set Point"]) {
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator co2SetPoint]];
                
                [arrDevice addObject:[devicesIncubator co2SetPoint]];
                
            }else if ([deviceType isEqualToString:@"O2 Set Point"]) {
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator o2SetPoint]];
                
                [arrDevice addObject:[devicesIncubator o2SetPoint]];
                
            }else if ([deviceType isEqualToString:@"High Temperature Limit"]) {
                
                //cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator highTemperatureLimit]];
                
                [arrDevice addObject:[devicesIncubator highTemperatureLimit]];
                
            }else if ([deviceType isEqualToString:@"Low Temperature Limit"]) {
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator lowTemperatureLimit]];
                
                [arrDevice addObject:[devicesIncubator lowTemperatureLimit]];
                
            }else if ([deviceType isEqualToString:@"High Co2 Limit"]) {
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator highCo2Limit]];
                
                [arrDevice addObject:[devicesIncubator highCo2Limit]];
                
            }else if ([deviceType isEqualToString:@"Low Co2 Limit"]) {
                
                //   cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator lowCo2Limit]];
                
                [arrDevice addObject:[devicesIncubator lowCo2Limit]];
                
            }else if ([deviceType isEqualToString:@"High O2 Limit"]) {
                
                //   cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator highO2Limit]];
                
                [arrDevice addObject:[devicesIncubator highO2Limit]];
                
                
            }else if ([deviceType isEqualToString:@"Low O2 Limit"]) {
                
                //    cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator lowO2Limit]];
                
                [arrDevice addObject:[devicesIncubator temperatureSetPoint]];
                
            }else if ([deviceType isEqualToString:@"Low Rh Limit"]) {
                
                //  cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator lowRhLimit]];
                
                [arrDevice addObject:[devicesIncubator lowRhLimit]];
                
            }else if ([deviceType isEqualToString:@"Temperature Sensor"]) {
                
                //      cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator temperatureSensor]];
                
                [arrDevice addObject:[devicesIncubator temperatureSensor]];
                
            }else if ([deviceType isEqualToString:@"Co2 Sensor"]) {
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator co2Sensor]];
                
                [arrDevice addObject:[devicesIncubator co2Sensor]];
                
            }else if ([deviceType isEqualToString:@"O2 Sensor"]) {
                
                //cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator o2Sensor]];
                [arrDevice addObject:[devicesIncubator o2Sensor]];
                
            }else if ([deviceType isEqualToString:@"Rh Sensor"]) {
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator rhSensor]];
                
                [arrDevice addObject:[devicesIncubator rhSensor]];
                
            }
            
            //cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesIncubator temperatureSensor]];
            
        }else if ([[devices deviceType] isEqualToString:@"ecs-g2"]){
            
            NSLog(@"Ecs g2");
            
            DevicesCurrentTemperature_EGS_G2 *devicesEGSG2 = [[ParserClass sharedItems] sensorLogs][i];
            
            //     cell.lblDate.text = [devicesEGSG2 occuranceTime];
            
            if ([deviceType isEqualToString:@"Low Inflow Limit"]) {
                
                //  cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesEGSG2 lowInflowLimit]];
                
                [arrDevice addObject:[devicesEGSG2 lowInflowLimit]];
                
            }else if ([deviceType isEqualToString:@"High Downflow Limit"]) {
                
                //   cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesEGSG2 highDownflowLimit]];
                
                [arrDevice addObject:[devicesEGSG2 highDownflowLimit]];
                
            }else if ([deviceType isEqualToString:@"Low Downflow Limit"]) {
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesEGSG2 lowDownflowLimit]];
                [arrDevice addObject:[devicesEGSG2 lowDownflowLimit]];
                
                
            }else if ([deviceType isEqualToString:@"High Temperature Limit"]) {
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesEGSG2 highTemperatureLimit]];
                
                [arrDevice addObject:[devicesEGSG2 highTemperatureLimit]];
                
            }else if ([deviceType isEqualToString:@"Low Temperature Limit"]) {
                
                //  cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesEGSG2 lowTemperatureLimit]];
                
                [arrDevice addObject:[devicesEGSG2 lowTemperatureLimit]];
                
            }else if ([deviceType isEqualToString:@"High DC Voltage Limit"]) {
                
                //  cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesEGSG2 highDcVoltageLimit]];
                
                [arrDevice addObject:[devicesEGSG2 highDcVoltageLimit]];
                
            }else if ([deviceType isEqualToString:@"Low DC Voltage Limit"]) {
                
                //  cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesEGSG2 lowDcVoltageLimit]];
                
                [arrDevice addObject:[devicesEGSG2 lowDcVoltageLimit]];
                
            }else if ([deviceType isEqualToString:@"Inflow Sensor"]) {
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesEGSG2 inflowsensor]];
                
                [arrDevice addObject:[devicesEGSG2 inflowsensor]];
                
            }else if ([deviceType isEqualToString:@"Downflow Sensor"]) {
                
                //cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesEGSG2 downflowSensor]];
                
                [arrDevice addObject:[devicesEGSG2 downflowSensor]];
                
                
            }else if ([deviceType isEqualToString:@"Temperature Sensor"]) {
                
                //cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesEGSG2 temperatureSensor]];
                
                [arrDevice addObject:[devicesEGSG2 temperatureSensor]];
                
            }else if ([deviceType isEqualToString:@"DC Voltage"]) {
                
                //cell.lblTemp.text = [NSString stringWithFormat:@"%@",[devicesEGSG2 dcVoltage]];
                
                [arrDevice addObject:[devicesEGSG2 dcVoltage]];
            }
            
            
            //  cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesEGSG2 temperatureSensor]];
            
        }else if ([[devices deviceType] isEqualToString:@"ofa"] || [[devices deviceType] isEqualToString:@"ifa"] || [[devices deviceType] isEqualToString:@"ifc"] || [[devices deviceType] isEqualToString:@"ina"]){
            
            NSLog(@"ofa ifa ifc ina");
            
            DevicesCurrentTemperature_OFA_IFA_IFC_INA *devicesOFAIFAIFCINA = [[ParserClass sharedItems] sensorLogs][i];
            
            // cell.lblDate.text = [devicesOFAIFAIFCINA occuranceTime];
            
            if ([deviceType isEqualToString:@"Chamber Set Point"]) {
                
                //cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesOFAIFAIFCINA chamberSetPoint]];
                
                [arrDevice addObject:[devicesOFAIFAIFCINA chamberSetPoint]];
                
            }else if ([deviceType isEqualToString:@"High Temperature Limit"]) {
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesOFAIFAIFCINA highTemperatureLimit]];
                [arrDevice addObject:[devicesOFAIFAIFCINA highTemperatureLimit]];
                
            }else if ([deviceType isEqualToString:@"Low Temperature Limit"]) {
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesOFAIFAIFCINA lowTemperatureLimit]];
                
                [arrDevice addObject:[devicesOFAIFAIFCINA lowTemperatureLimit]];
                
            }else if ([deviceType isEqualToString:@"Chamber Temperature Sensor"]) {
                
                // cell.lblTemp.text = [NSString stringWithFormat:@"%@°C",[devicesOFAIFAIFCINA chamberTemperatureSensor]];
                
                [arrDevice addObject:[devicesOFAIFAIFCINA chamberTemperatureSensor]];
                
                
            }
            
            
            
            
        }
    }
    
    NSLog(@"arrDevices = %i", [arrDevice count]);
    //   return arrDevices;
    
    
    
}
@end
